<template>
	<view>
		<!-- 平分 -->
		<!-- <view class="padding-lr bg-black">
			<scroll-view scroll-x class="bg-black nav">
				<view class="flex text-center">
					<view class="cu-item flex-sub" :class="k==TabCur?'active cur':''" v-for="(i,k) in tabs" :key="k" @tap="tabSelect"
					 :data-id="k">
						{{i}}
					</view>
				</view>
			</scroll-view>
		</view> -->
		
		<view class="padding-bottom-xs blank">
			
		</view>
		
		<view class="padding-lr bg-white" v-if="TabCur==0">
			<view class="cu-form-group">
				<view class="title">原始密码</view>
				<input v-model="form1.oldpwd" password placeholder="请输入" name="input"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">新密码</view>
				<input v-model="form1.newpwd" password placeholder="请输入" name="input"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">确认新密码</view>
				<input v-model="form1.newpwd2" password placeholder="请输入" name="input"></input>
			</view>
		</view>
		
		<view class="padding-lr bg-white" v-if="TabCur==1">
			<view class="cu-form-group">
				<view class="title">新密码</view>
				<input placeholder="未开放" name="input" disabled></input>
			</view>
			<!-- <view class="cu-form-group">
				<view class="title">确认新密码</view>
				<input placeholder="请输入" name="input"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">验证码</view>
				<input placeholder="请输入" name="input"></input>
				<button class="cu-btn bg-green shadow" :disabled="num != '验证码'" @click="countDown">{{num}}</button>
			</view> -->
		</view>
		
		<view class="padding" style="margin-top: 200rpx;">
			<my-btn class="block" bg="#999999" @click.native="submit">修改</my-btn>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				TabCur: 0,
				scrollLeft: 0,
				tabs: ['账户密码', '交易密码'],
				flag: 1,
				num: '验证码',
				form1: {
					oldpwd: '',
					newpwd: '',
					newpwd2: ''
				}
			}
		},
		methods: {
			tabSelect(e) {
				this.TabCur = e.currentTarget.dataset.id;
				this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
			},
			countDown() {
				if (this.flag) {
					this.flag = 0
					this.num = 60
				}
				this.num = this.num - 1
				console.log(this.num)
				if (this.num == 0) {
					this.flag = 1
					this.num = '验证码'
					return;
				} else {
					setTimeout(() => {
						this.countDown()
					}, 1000)
				}
			},
			submit() {
				if (this.TabCur == 0) {
					this.pwdReset()
				} else {
					
				}
			},
			pwdReset() {
				if (this.form1.newpwd == this.form1.newpwd2) {
					this.$u.post('/user/pwdReset', this.form1).then(res => {
						this.$msg(res.data.msg)
						if (res.data.success) {
							
						}
					})
				} else {
					this.$msg('两次密码不一样')
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #F4F4F4;
	}
	.title {
		width: 180rpx;
	}
	.bg-black {
		background-color: #1f1f1f;
	}
	.nav {
		.active {
			color: #DAC295;
		}
	}
</style>
